package wdn.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.dom.client.KeyPressHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;

public class adm1 implements EntryPoint {

	private static final String SERVER_ERROR = "An error occurred while "
			+ "attempting to contact the server. Please check your network "
			+ "connection and try again.";

	/**
	 * Create a remote service proxy to talk to the server-side Greeting service.
	 */
	private final Adm1ServAsync adm1Serv = GWT.create(Adm1Serv.class);

	
	private VerticalPanel mainPanel = new VerticalPanel();
	private HorizontalPanel addPanel = new HorizontalPanel();
	private FlexTable guestsFlexTable = new FlexTable();
	private TextBox newGTextBox = new TextBox();
	private TextBox newETextBox = new TextBox();
	private Button addGButton = new Button("Add");
	private Label lastUpdatedLabel = new Label();

	
	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
		// Create table for guests.
	    guestsFlexTable.setText(0, 0, "Name");
	    guestsFlexTable.setText(0, 1, "E-Mail");
	    guestsFlexTable.setText(0, 2, "Total");
	    guestsFlexTable.setText(0, 3, "Hash");
	    guestsFlexTable.setText(0, 4, "4 Sep");
	    guestsFlexTable.setText(0, 5, "12 Sep");

	    // Guests Add panel.
	    addPanel.add(newGTextBox);
	    addPanel.add(newETextBox);
	    addPanel.add(addGButton);

	    // Assemble Main panel.
	    mainPanel.add(guestsFlexTable);
	    mainPanel.add(addPanel);
	    mainPanel.add(lastUpdatedLabel);

		// Associate the Main panel with the HTML host page.
	    RootPanel.get("guestsList").add(mainPanel);
	    
	    // Move cursor focus to the input box.
	    newGTextBox.setFocus(true);

	    // Listen for mouse events on the Add button.
	    addGButton.addClickHandler(new ClickHandler() {
	      public void onClick(ClickEvent event) {
	        addGuest();
	      }
	    });

	    // Listen for keyboard events in the input box.
	    newGTextBox.addKeyPressHandler(new KeyPressHandler() {
	      public void onKeyPress(KeyPressEvent event) {
	        if (event.getCharCode() == KeyCodes.KEY_ENTER) {
	          addGuest();
	        }
	      }
	    });

	}


	private void addGuest() {
		
	}

}
